package felix.dataviewer.adp;

import android.widget.ImageView;
import android.widget.TextView;

import felix.dataviewer.Data.AppBean;
import felix.dataviewer.Data.DBBean;
import felix.dataviewer.R;
import felix.felixlib.Base.adp.eadp.BaseCVH;
import felix.felixlib.Base.adp.eadp.BaseEAdp;
import felix.felixlib.Base.adp.eadp.BaseGVH;
import felix.felixlib.annotation.BindLayout;
import felix.felixlib.annotation.BindView;

/**
 * Created by huangmf on 8/16/2017.
 */
@BindLayout({R.layout.eadp_itm_app, R.layout.eadp_item_db})
public class AppEAdp extends BaseEAdp<DBBean, AppBean, AppEAdp.AppVH, AppEAdp.DBVH> {

    class AppVH extends BaseGVH<AppBean> {
        @BindView(R.id.iv_icon)
        ImageView mIvIcon;
        @BindView(R.id.tv_label)
        TextView mTvLabel;
        @BindView(R.id.tv_pkg_name)
        TextView mTvPkgName;

        @Override
        protected void setData(AppBean appBean, int position, int size) {
            super.setData(appBean, position, size);
            mIvIcon.setImageDrawable(appBean.getIcon());
            mTvLabel.setText(appBean.getLabel());
            mTvPkgName.setText(appBean.getPkgName());
        }
    }

    class DBVH extends BaseCVH<DBBean> {
        @BindView(R.id.tv_dbname)
        TextView mTvDBName;

        @Override
        protected void setData(DBBean dbBean, int groupPosition, int childPosition, int size) {
            super.setData(dbBean, groupPosition, childPosition, size);
            mTvDBName.setText(dbBean.getName());
        }
    }
}
